package org.come.xinyuan;

import com.tool.btn.MoBanBtn;
import com.tool.role.RoleData;
import come.tool.JDialog.TiShiUtil;
import org.apache.commons.lang.StringUtils;
import org.come.Frame.OptionsJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.ZhuJpanel;
import org.come.bean.Skill;
import org.come.entity.RoleSummoning;
import org.come.until.UserMessUntil;

import java.awt.*;
import java.awt.event.MouseEvent;

public class SkillTYCBtn6 extends MoBanBtn {
    private int typeBtn;
    private CopyOfSkillTYCPanel5 skillTYCPanel;

    public SkillTYCBtn6(String iconpath, int type, Color[] colors, String text, Font font, int typeBtn, CopyOfSkillTYCPanel5 skillTYCPanel) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setHorizontalTextPosition(0);
        this.setVerticalTextPosition(0);
        this.typeBtn = typeBtn;
        this.skillTYCPanel = skillTYCPanel;
    }


    @Override
    public void chooseyes() {
    }

    @Override
    public void chooseno() {
    }

    @Override
    public void nochoose(MouseEvent e) {
        RoleSummoning pet = UserMessUntil.getChosePetMes();
        if (typeBtn == 1) {
            if (pet == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("未选中召唤兽");
            } else if (pet != null && !"200193".equals(pet.getSummoningid())) {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽并不是心猿");
            } else {
                if (pet.getXinyuan() == null) {
                    OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.DuiXinYuan, UserMessUntil.getChosePetMes().getSid(), "#Y兑换心意点需要#R10#Y个#G珍稀神兽碎片#Y为#G" + UserMessUntil.getChosePetMes().getSummoningname() + "#Y增加心意点？");
                } else {
                    int ds = ((pet != null && StringUtils.isNotBlank(pet.getXinyuan()) ? Integer.parseInt(pet.getXinyuan().split("&")[0]) : 0) + 1) * 3;//("&")[0]) : 0) + 1) * 30 + 20;
                    OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.DuiXinYuan, UserMessUntil.getChosePetMes().getSid(), "#Y兑换心意点需要#R" + ds + "#Y个#G珍稀神兽碎片#Y为#G" + UserMessUntil.getChosePetMes().getSummoningname() + "#Y增加心意点？");
                }

            }
        } else if (typeBtn == 2) {
            if (pet == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("未选中召唤兽");
            } else if (pet != null && !"200193".equals(pet.getSummoningid())) {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽并不是心猿");
            } else {
                if (pet.getXinyuan() == null) {
                    ZhuFrame.getZhuJpanel().addPrompt2("还没有加点");
                } else {
                    OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.XiXinYuan, UserMessUntil.getChosePetMes().getSid(), "#Y洗点需消耗#R20000#Y仙玉，会清空所有心猿技能返还心意点。");
                }

            }
        } else if (typeBtn == 3) {//成圣
            if (pet == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("未选中召唤兽");
            }
            if ((pet.getXinyuan() != null ? Integer.parseInt(pet.getXinyuan().split("&")[0]) : 0) < 12) {
                ZhuFrame.getZhuJpanel().addPrompt2("心意点不足12,无法成圣!");
                return;
            }
            if (pet.getPetSkills() == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("未学习终极技能,无法成圣!");
                return;
            }
            String[] petnaturalskill = pet.getPetSkills().split("\\|");
            boolean isZjskill = true;
            for (int i = 0; i < petnaturalskill.length; i++) {
                Skill skill = UserMessUntil.getSkillBean().getSkillMap().get(petnaturalskill[i]);
                if ("3".equals(skill.getSkilltype()) || "4".equals(skill.getSkilltype())) {
                    isZjskill = false;
                    break;
                }
            }
            if (isZjskill) {
                ZhuFrame.getZhuJpanel().addPrompt2("未学习终极技能,无法成圣!");
                return;
            }
            if (pet.getPetlock() == 1) {
                ZhuFrame.getZhuJpanel().addPrompt("已加锁,无法成圣!");
                return;
            }
            if (pet.getGoods() != null) {
                ZhuFrame.getZhuJpanel().addPrompt("携带着装备,无法成圣!");
                return;
            }
            if (ZhuJpanel.getPetMount(pet.getSid()) != null) {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽被管制中，无法成圣！！！");
                return;
            }
            if (RoleData.getRoleData().getLoginResult().getSummoning_id() != null) {
                if (RoleData.getRoleData().getLoginResult().getSummoning_id().compareTo(pet.getSid()) == 0) {
                    ZhuFrame.getZhuJpanel().addPrompt2("参战中,无法成圣！！！");
                    return;
                }
            }
            OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.Chengsheng, UserMessUntil.getChosePetMes().getSid(), "#Y西经十三条心路，如今心意已决，成圣原在于心之一合，一念成圣之后，心猿将会变成为#G神兽一念圣猿#Y，顿悟全新形象/属性/天生技能");
        } else {
            if (typeBtn == 4) {
                this.skillTYCPanel.addPoint();
            }

        }
    }
}